<?php

/**
 * Campaign form base class.
 *
 * @method Campaign getObject() Returns the current form's model object
 *
 * @package    25Mails
 * @subpackage form
 * @author     fabio.lorenzini@25solutions.com
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCampaignForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'campaign_id'       => new sfWidgetFormInputHidden(),
      'name'              => new sfWidgetFormInputText(),
      'description'       => new sfWidgetFormTextarea(),
      'continuous'        => new sfWidgetFormInputCheckbox(),
      'start_date'        => new sfWidgetFormDateTime(),
      'stop_date'         => new sfWidgetFormDateTime(),
      'template_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Template'), 'add_empty' => false)),
      'status'            => new sfWidgetFormChoice(array('choices' => array('NOT_INIT' => 'NOT_INIT', 'TO_DO' => 'TO_DO', 'ONGOING' => 'ONGOING', 'DONE' => 'DONE', 'ERROR' => 'ERROR'))),
      'recipients_filter' => new sfWidgetFormTextarea(),
      'tags_filter'       => new sfWidgetFormTextarea(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
      'deleted_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'campaign_id'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('campaign_id')), 'empty_value' => $this->getObject()->get('campaign_id'), 'required' => false)),
      'name'              => new sfValidatorString(array('max_length' => 255)),
      'description'       => new sfValidatorString(array('required' => false)),
      'continuous'        => new sfValidatorBoolean(array('required' => false)),
      'start_date'        => new sfValidatorDateTime(),
      'stop_date'         => new sfValidatorDateTime(array('required' => false)),
      'template_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Template'))),
      'status'            => new sfValidatorChoice(array('choices' => array(0 => 'NOT_INIT', 1 => 'TO_DO', 2 => 'ONGOING', 3 => 'DONE', 4 => 'ERROR'), 'required' => false)),
      'recipients_filter' => new sfValidatorString(array('required' => false)),
      'tags_filter'       => new sfValidatorString(array('required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
      'deleted_at'        => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('campaign[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Campaign';
  }

}
